package com.azkj.album.utils;

import android.app.Activity;
import android.content.SharedPreferences;

import com.azkj.album.MyApplication;

public class SpUtils {

    public static void putString(String key, String value) {
        getSp().edit().putString(key, value).apply();
    }


    public static String getString(String key, String defValue) {
        return getSp().getString(key, defValue);
    }


    public static void putBoolean(String key, boolean value) {
        getSp().edit().putBoolean(key, value).apply();
    }


    public static boolean getBoolean(String key, boolean defValue) {
        return getSp().getBoolean(key, defValue);
    }


    public static void putInt(String key, int value) {
        getSp().edit().putInt(key, value).apply();
    }


    public static int getInt(String key, int defValue) {
        return getSp().getInt(key, defValue);
    }


    public static void clear(String key) {
        getSp().edit().remove(key).apply();
    }


    public static void clearAll() {
        getSp().edit().clear().apply();
    }


    public static SharedPreferences getSp() {
        return MyApplication.getApplication().getSharedPreferences("sp",
                Activity.MODE_PRIVATE);

    }


}
